import React, { Component } from 'react';

import { inject, observer } from 'mobx-react';
import { toJS } from 'mobx'
import { List, Tools, SearchBar } from "weaver-mobile";
import { ListPage } from 'weaver-mobile-page';
import { withRouter } from 'react-router-dom';


const Item = List.Item;
const Normal = ListPage.Normal;
const getLabel = Tools.getLabel;
const template = {
    default: [
        {
            key: 'col1',
            configs: [
                {
                    key: 'col1_row1',
                    configs: [
                        {
                            key: 'showname',
                            style: { fontWeight: "normal" }},
                    ],
                }
            ],
        },
    ],
};
@inject("wfAgentStore")
@withRouter
@observer
export default class SelectIdentatity extends Component {
    componentWillMount() {
        const { addAgent } = this.props.wfAgentStore;
        const { selectIdentatity_data } = addAgent;
    }
    componentDidMount() {
        const { addAgent } = this.props.wfAgentStore;
        const { selectIdentatity_data, list_selectIdentatity,bagentuid_identatity } = addAgent;
        list_selectIdentatity.setState({ data: selectIdentatity_data, selectedRowKeys: [bagentuid_identatity.key] });
    }

    onRowSelect = (selectedRowKeys) => {
        const { addAgent, setAddAgent } = this.props.wfAgentStore;
        const { selectIdentatity_data } = addAgent;
        selectIdentatity_data.map(item => {
            if (item.key === selectedRowKeys[0]) {
                setAddAgent({ bagentuid_identatity:item})
            }
        })
    }
    render() {
        const { addAgent } = this.props.wfAgentStore;
        const { list_selectIdentatity } = addAgent;
        return (
            <div className="wf-addagent-identatity-list">
                {/* <div className="wf_agent_page_title">选择身份</div> */}
                <Normal
                    showCheck
                    rowKey={"key"}
                    template={template}
                    store={list_selectIdentatity}
                    onRowSelect={this.onRowSelect}
                />
            </div>
        );
    }

}